{% extends "base.html" %}
{% load pretty_user %}
{% load match %}
{% load partial_template %}
{% load site_user %}

{% block additional_title %}
Šahovske statistike
{% endblock %}

{% block nav %}
{% partial_template navigation.html selected_tab:"statistics" user:user perms:perms %}
{% endblock %}

{% block content %}
<center><h2>Statistike za stoni fudbal</h2></center>
<div>
	<table class="tablesorter" id="mainTable">
		<tbody>
			<tr>
				<td>Najviše poena:</td>
				<td>
				{% for user in tf_stat.best_users %}
				{{ user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{% if tf_stat.best_users.0.tf_points %}
				{{ tf_stat.best_users.0.tf_points }}
				{% else %}
				/
				{% endif %}
				</td>
			</tr>
			<tr>
				<td>Najmanje poena:</td>
				<td>
				{% for user in tf_stat.worst_users %}
				{{ user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{% if tf_stat.worst_users.0.tf_points %}
				{{ tf_stat.worst_users.0.tf_points }}
				{% else %}
				/
				{% endif %}
				</td>
			</tr>
			<tr>
				<td>Poslednje odigrani meč</td>
				{% if tf_stat.last_played_match %}
				<td>{{ tf_stat.last_played_match|match }}</td>
				<td>{{ tf_stat.last_played_match.result }} ({{ tf_stat.last_played_match.date_played|date }} {{ tf_stat.last_played_match.date_played|time }})</td>
				{% else %}
				<td>/</td>
				<td>/</td>
				{% endif %}
			</tr>
			<tr>
				<td>Najviše odigranih mečeva:</td>
				<td>
				{% for most_played in tf_stat.um_agg.most_played %}
				{{ most_played.user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{% if tf_stat.um_agg.most_played.0.played %}
				{{ tf_stat.um_agg.most_played.0.played }}
				{% else %}
				/
				{% endif %}
				</td>
			</tr>
			<tr>
				<td>Najviše pobeda:</td>
				<td>
				{% for most_won in tf_stat.um_agg.most_won %}
				{{ most_won.user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{{ tf_stat.um_agg.most_won.0.won }}/{{ tf_stat.um_agg.most_won.0.played }}
				</td>
			</tr>
			<tr>
				<td>Najviše pobeda (%):</td>
				<td>
				{% for most_won_percent in tf_stat.um_agg.most_won_percent %}
				{{ most_won_percent.user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{{ tf_stat.um_agg.most_won_percent.0.percent_won|stringformat:".2f" }}%
				({{ tf_stat.um_agg.most_won_percent.0.won }}/{{ tf_stat.um_agg.most_won_percent.0.played }})
				</td>
			</tr>
			<tr>
				<td>Najviše poraza:</td>
				<td>
				{% for most_lost in tf_stat.um_agg.most_lost %}
				{{ most_lost.user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{{ tf_stat.um_agg.most_lost.0.lost }}/{{ tf_stat.um_agg.most_lost.0.played }}
				</td>
			</tr>
			<tr>
				<td>Najviše poraza (%):</td>
				<td>
				{% for most_lost_percent in tf_stat.um_agg.most_lost_percent %}
				{{ most_lost_percent.user|pretty_user }}
				<br/>
				{% empty %}
				/
				{% endfor %}
				</td>
				<td>
				{{ tf_stat.um_agg.most_lost_percent.0.percent_lost|stringformat:".2f" }}%
				({{ tf_stat.um_agg.most_lost_percent.0.lost }}/{{ tf_stat.um_agg.most_lost_percent.0.played }})
				</td>
			</tr>
			<tr>
				<td>Najčešći saigrači</td>
				<td>
					<table>
						<tbody>
							{% for teammates in tf_stat.teammates %}
							<tr>
								<td style="text-align: right;">{{ teammates.0.0|pretty_user }}</td>
								<td style="text-align: left;">{{ teammates.0.1|pretty_user }}</td>
							</tr>
							{% empty %}
							/
							{% endfor %}
						</tbody>
					</table>
				</td>
				<td>
				{% if tf_stat.teammates.0.1 %}
				{{ tf_stat.teammates.0.1 }}
				{% else %}
				/
				{% endif %}
				</td>
			</tr>
			<tr>
				<td>Najčešći protivnici</td>
				<td>
					<table>
						<tbody>
							{% for opponent in tf_stat.opponents %}
							<tr>
								<td style="text-align: right;">{{ opponent.0.0|pretty_user }}</td>
								<td style="text-align: left;">{{ opponent.0.1|pretty_user }}</td>
							</tr>
							{% empty %}
							/
							{% endfor %}
						</tbody>
					</table>
				</td>
				<td>
				{% if tf_stat.opponents.0.1 %}
				{{ tf_stat.opponents.0.1 }}
				{% else %}
				/
				{% endif %}
				</td>
			</tr>
		</tbody>
	</table>
</div>

{% endblock %}
